#include<iostream>
using namespace std;


struct TreeNode {
      int val;
      TreeNode *left;
      TreeNode *right;
 };
 


class Solution {
public:
    TreeNode* searchBST(TreeNode* root, int val) {
        
        if(root==NULL||root->val==val)return root;
        TreeNode *res=NULL;
        if(root->val<val)res=searchBST(root->right, val);
        if(root->val>val)res=searchBST(root->left, val);
        return res;
    }
};